package com.ygly.struts.href;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ygly.struts.actions.SqlAction;
import com.ygly.struts.models.Pro;
import com.ygly.struts.models.User;

public class Href8Action extends ActionSupport {

	/**
	 * @return
	 */
	public List<Pro> prolist;
	public List<Pro> list = new ArrayList<Pro>();
	public List<Pro> getProlist() {
		return prolist;
	}
	public void setProlist(List<Pro> prolist) {
		this.prolist = prolist;
	}
	public String execute()throws Exception {
		// TODO Auto-generated method stub
		ActionContext con = ActionContext.getContext();
		Map session = con.getSession();
		User user = (User )session.get("user");
		int id = user.getId();
		SqlAction sql = new SqlAction();
		sql.OpenConn();
		String query = "select * from stu_pro where Com_Id = '"+id+"' and State=0";
		ResultSet rs = sql.executeQuery(query);
		while(rs.next()){
			Pro pro = new Pro();
			pro.setId(rs.getInt("Pro_Id"));
			pro.setName(rs.getString("Pro_Name"));
			pro.setCom_name(rs.getString("Stu_Name"));
			pro.setCreatetime(rs.getDate("Createtime"));
			list.add(pro);
		}
		this.setProlist(list);
		return "SUCCESS";
	}
}